home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2005 October / PCWOCT05.iso / Software / FromTheMag / XAMPP 1.4.14 / xampp-win32-1.4.14-installer.exe / xampp / php / pear / HTML / Progress / model.php < prev    next >
Encoding:
PHP Script  |  2004-03-24  |  4.2 KB  |  109 lines

  1. <?php
  2. // +----------------------------------------------------------------------+
  3. // | PHP Version 4                                                        |
  4. // +----------------------------------------------------------------------+
  5. // | Copyright (c) 1997-2003 The PHP Group                                |
  6. // +----------------------------------------------------------------------+
  7. // | This source file is subject to version 3.0 of the PHP license,       |
  8. // | that is bundled with this package in the file LICENSE, and is        |
  9. // | available at through the world-wide-web at                           |
  10. // | http://www.php.net/license/3_0.txt.                                  |
  11. // | If you did not receive a copy of the PHP license and are unable to   |
  12. // | obtain it through the world-wide-web, please send a note to          |
  13. // | license@php.net so we can mail you a copy immediately.               |
  14. // +----------------------------------------------------------------------+
  15. // | Author: Laurent Laville <pear@laurent-laville.org>                   |
  16. // +----------------------------------------------------------------------+
  17. //
  18. // $Id: model.php,v 1.1 2003/11/15 18:27:09 thesaur Exp $
  19.  
  20. /**
  21.  * The HTML_Progress_Model class provides an easy way to set look and feel 
  22.  * of a progress bar with external config file.
  23.  *
  24.  * @version    1.0
  25.  * @author     Laurent Laville <pear@laurent-laville.org>
  26.  * @access     public
  27.  * @category   HTML
  28.  * @package    HTML_Progress
  29.  * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
  30.  */
  31.  
  32. require_once ('Config.php');
  33.  
  34. class HTML_Progress_Model extends HTML_Progress_UI
  35. {
  36.     /**
  37.      * Package name used by Error_Raise functions
  38.      *
  39.      * @var        string
  40.      * @since      1.0
  41.      * @access     private
  42.      */
  43.     var $_package;
  44.  
  45.  
  46.     /**
  47.      * The progress bar's UI extended model class constructor
  48.      *
  49.      * @param      string    $file          file name of model properties
  50.      * @param      string    $type          type of external ressource (phpArray, iniFile, XML ...)
  51.      *
  52.      * @since      1.0
  53.      * @access     public
  54.      * @throws     HTML_PROGRESS_ERROR_INVALID_INPUT
  55.      */
  56.     function HTML_Progress_Model($file, $type)
  57.     {
  58.         $this->_package = 'HTML_Progress_Model';
  59.         Error_Raise::initialize($this->_package, array('HTML_Progress', '_getErrorMessage'));
  60.  
  61.         if (!file_exists($file)) {
  62.             return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'error',
  63.                 array('var' => '$file',
  64.                       'was' => $file,
  65.                       'expected' => 'file exists',
  66.                       'paramnum' => 1), PEAR_ERROR_TRIGGER);
  67.         }
  68.  
  69.         $conf = new Config();
  70.  
  71.         if (!$conf->isConfigTypeRegistered($type)) {
  72.             return Error_Raise::raise($this->_package, HTML_PROGRESS_ERROR_INVALID_INPUT, 'error',
  73.                 array('var' => '$type',
  74.                       'was' => $type,
  75.                       'expected' => implode (" | ", array_keys($GLOBALS['CONFIG_TYPES'])),
  76.                       'paramnum' => 2), PEAR_ERROR_TRIGGER);
  77.         }
  78.  
  79.         $data = $conf->parseConfig($file, $type);
  80.  
  81.         $structure = $data->toArray(false);
  82.         $this->_progress =& $structure['root'];
  83.         
  84.         if (is_array($this->_progress['cell']['font-family'])) {
  85.             $this->_progress['cell']['font-family'] = implode(",", $this->_progress['cell']['font-family']);
  86.         }
  87.         if (is_array($this->_progress['string']['font-family'])) {
  88.             $this->_progress['string']['font-family'] = implode(",", $this->_progress['string']['font-family']);
  89.         }
  90.         $this->_orientation = $this->_progress['orientation']['shape'];
  91.         $this->_fillWay = $this->_progress['orientation']['fillway'];
  92.         
  93.         if (isset($this->_progress['script']['file'])) {
  94.             $this->_script = $this->_progress['script']['file'];
  95.         } else {
  96.             $this->_script = null;
  97.         }
  98.  
  99.         if (isset($this->_progress['cell']['count'])) {
  100.             $this->_cellCount = $this->_progress['cell']['count'];
  101.         } else {
  102.             $this->_cellCount = 10;
  103.         }
  104.  
  105.         $this->_updateProgressSize();
  106.     }
  107. }
  108.  
  109. ?>